<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QVector2D Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QVector2D Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QVector2D class represents a vector or vertex in 2D space.
<a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qvector2d.html#QVector2D">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#QVector2D-2">__init__</a></b> (<i>self</i>, float&#160;<i>xpos</i>, float&#160;<i>ypos</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#QVector2D-3">__init__</a></b> (<i>self</i>, QPoint&#160;<i>point</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#QVector2D-4">__init__</a></b> (<i>self</i>, QPointF&#160;<i>point</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#QVector2D-5">__init__</a></b> (<i>self</i>, QVector3D&#160;<i>vector</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#QVector2D-6">__init__</a></b> (<i>self</i>, QVector4D&#160;<i>vector</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#QVector2D-7">__init__</a></b> (<i>self</i>, QVector2D)</li><li><div class="fn" />bool <b><a href="qvector2d.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qvector2d.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qvector2d.html#lengthSquared">lengthSquared</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#normalize">normalize</a></b> (<i>self</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#normalized">normalized</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#setX">setX</a></b> (<i>self</i>, float&#160;<i>aX</i>)</li><li><div class="fn" /><b><a href="qvector2d.html#setY">setY</a></b> (<i>self</i>, float&#160;<i>aY</i>)</li><li><div class="fn" />QPoint <b><a href="qvector2d.html#toPoint">toPoint</a></b> (<i>self</i>)</li><li><div class="fn" />QPointF <b><a href="qvector2d.html#toPointF">toPointF</a></b> (<i>self</i>)</li><li><div class="fn" />QVector3D <b><a href="qvector2d.html#toVector3D">toVector3D</a></b> (<i>self</i>)</li><li><div class="fn" />QVector4D <b><a href="qvector2d.html#toVector4D">toVector4D</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qvector2d.html#x">x</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qvector2d.html#y">y</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />float <b><a href="qvector2d.html#dotProduct">dotProduct</a></b> (QVector2D&#160;<i>v1</i>, QVector2D&#160;<i>v2</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__add__">__add__</a></b> (<i>self</i>, QVector2D&#160;<i>v2</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__div__">__div__</a></b> (<i>self</i>, float&#160;<i>divisor</i>)</li><li><div class="fn" />bool <b><a href="qvector2d.html#__eq__">__eq__</a></b> (<i>self</i>, QVector2D&#160;<i>v2</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__iadd__">__iadd__</a></b> (<i>self</i>, QVector2D&#160;<i>vector</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__idiv__">__idiv__</a></b> (<i>self</i>, float&#160;<i>divisor</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__imul__">__imul__</a></b> (<i>self</i>, float&#160;<i>factor</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__imul__-2">__imul__</a></b> (<i>self</i>, QVector2D&#160;<i>vector</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__isub__">__isub__</a></b> (<i>self</i>, QVector2D&#160;<i>vector</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__mul__">__mul__</a></b> (<i>self</i>, QVector2D&#160;<i>vector</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__mul__-2">__mul__</a></b> (<i>self</i>, float&#160;<i>factor</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__mul__-3">__mul__</a></b> (<i>self</i>, QVector2D&#160;<i>v2</i>)</li><li><div class="fn" />bool <b><a href="qvector2d.html#__ne__">__ne__</a></b> (<i>self</i>, QVector2D&#160;<i>v2</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__neg__">__neg__</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qvector2d.html#__repr__">__repr__</a></b> (<i>self</i>)</li><li><div class="fn" />QVector2D <b><a href="qvector2d.html#__sub__">__sub__</a></b> (<i>self</i>, QVector2D&#160;<i>v2</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>This class can be pickled.</p><p>The QVector2D class represents a vector or vertex in 2D
space.</p>
<p>The QVector2D class can also be used to represent vertices in 2D
space. We therefore do not need to provide a separate vertex
class.</p>
<p><b>Note:</b> By design values in the QVector2D instance are
stored as <tt>float</tt>. This means that on platforms where the
<tt>qreal</tt> arguments to QVector2D functions are represented by
<tt>double</tt> values, it is possible to lose precision.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QVector2D" />QVector2D.__init__ (<i>self</i>)</h3><p>Constructs a null vector, i.e. with coordinates (0, 0, 0).</p>


<h3 class="fn"><a name="QVector2D-2" />QVector2D.__init__ (<i>self</i>, float&#160;<i>xpos</i>, float&#160;<i>ypos</i>)</h3><p>Constructs a vector with coordinates (<i>xpos</i>,
<i>ypos</i>).</p>


<h3 class="fn"><a name="QVector2D-3" />QVector2D.__init__ (<i>self</i>, <a href="qpoint.html">QPoint</a>&#160;<i>point</i>)</h3><p>Constructs a vector with x and y coordinates from a 2D
<i>point</i>.</p>


<h3 class="fn"><a name="QVector2D-4" />QVector2D.__init__ (<i>self</i>, <a href="qpointf.html">QPointF</a>&#160;<i>point</i>)</h3><p>Constructs a vector with x and y coordinates from a 2D
<i>point</i>.</p>


<h3 class="fn"><a name="QVector2D-5" />QVector2D.__init__ (<i>self</i>, <a href="qvector3d.html">QVector3D</a>&#160;<i>vector</i>)</h3><p>Constructs a vector with x and y coordinates from a 3D
<i>vector</i>. The z coordinate of <i>vector</i> is dropped.</p>
<p><b>See also</b> <a href="qvector2d.html#toVector3D">toVector3D</a>().</p>


<h3 class="fn"><a name="QVector2D-6" />QVector2D.__init__ (<i>self</i>, <a href="qvector4d.html">QVector4D</a>&#160;<i>vector</i>)</h3><p>Constructs a vector with x and y coordinates from a 3D
<i>vector</i>. The z and w coordinates of <i>vector</i> are
dropped.</p>
<p><b>See also</b> <a href="qvector2d.html#toVector4D">toVector4D</a>().</p>


<h3 class="fn"><a name="QVector2D-7" />QVector2D.__init__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>)</h3><h3 class="fn"><a name="dotProduct" />float QVector2D.dotProduct (<a href="qvector2d.html">QVector2D</a>&#160;<i>v1</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>v2</i>)</h3><p>Returns the dot product of <i>v1</i> and <i>v2</i>.</p>


<h3 class="fn"><a name="isNull" />bool QVector2D.isNull (<i>self</i>)</h3><p>Returns true if the x and y coordinates are set to 0.0,
otherwise returns false.</p>


<h3 class="fn"><a name="length" />float QVector2D.length (<i>self</i>)</h3><p>Returns the length of the vector from the origin.</p>
<p><b>See also</b> <a href="qvector2d.html#lengthSquared">lengthSquared</a>() and <a href="qvector2d.html#normalized">normalized</a>().</p>


<h3 class="fn"><a name="lengthSquared" />float QVector2D.lengthSquared (<i>self</i>)</h3><p>Returns the squared length of the vector from the origin. This
is equivalent to the dot product of the vector with itself.</p>
<p><b>See also</b> <a href="qvector2d.html#length">length</a>() and
<a href="qvector2d.html#dotProduct">dotProduct</a>().</p>


<h3 class="fn"><a name="normalize" />QVector2D.normalize (<i>self</i>)</h3><p>Normalizes the currect vector in place. Nothing happens if this
vector is a null vector or the length of the vector is very close
to 1.</p>
<p><b>See also</b> <a href="qvector2d.html#length">length</a>() and
<a href="qvector2d.html#normalized">normalized</a>().</p>


<h3 class="fn"><a name="normalized" /><a href="qvector2d.html">QVector2D</a> QVector2D.normalized (<i>self</i>)</h3><p>Returns the normalized unit vector form of this vector.</p>
<p>If this vector is null, then a null vector is returned. If the
length of the vector is very close to 1, then the vector will be
returned as-is. Otherwise the normalized form of the vector of
length 1 will be returned.</p>
<p><b>See also</b> <a href="qvector2d.html#length">length</a>() and
<a href="qvector2d.html#normalize">normalize</a>().</p>


<h3 class="fn"><a name="setX" />QVector2D.setX (<i>self</i>, float&#160;<i>aX</i>)</h3><p>Sets the x coordinate of this point to the given <i>x</i>
coordinate.</p>
<p><b>See also</b> <a href="qvector2d.html#x">x</a>() and <a href="qvector2d.html#setY">setY</a>().</p>


<h3 class="fn"><a name="setY" />QVector2D.setY (<i>self</i>, float&#160;<i>aY</i>)</h3><p>Sets the y coordinate of this point to the given <i>y</i>
coordinate.</p>
<p><b>See also</b> <a href="qvector2d.html#y">y</a>() and <a href="qvector2d.html#setX">setX</a>().</p>


<h3 class="fn"><a name="toPoint" /><a href="qpoint.html">QPoint</a> QVector2D.toPoint (<i>self</i>)</h3><p>Returns the <a href="qpoint.html">QPoint</a> form of this 2D
vector.</p>
<p><b>See also</b> <a href="qvector2d.html#toPointF">toPointF</a>()
and <a href="qvector2d.html#toVector3D">toVector3D</a>().</p>


<h3 class="fn"><a name="toPointF" /><a href="qpointf.html">QPointF</a> QVector2D.toPointF (<i>self</i>)</h3><p>Returns the <a href="qpointf.html">QPointF</a> form of this 2D
vector.</p>
<p><b>See also</b> <a href="qvector2d.html#toPoint">toPoint</a>()
and <a href="qvector2d.html#toVector3D">toVector3D</a>().</p>


<h3 class="fn"><a name="toVector3D" /><a href="qvector3d.html">QVector3D</a> QVector2D.toVector3D (<i>self</i>)</h3><p>Returns the 3D form of this 2D vector, with the z coordinate set
to zero.</p>
<p><b>See also</b> <a href="qvector2d.html#toVector4D">toVector4D</a>() and <a href="qvector2d.html#toPoint">toPoint</a>().</p>


<h3 class="fn"><a name="toVector4D" /><a href="qvector4d.html">QVector4D</a> QVector2D.toVector4D (<i>self</i>)</h3><p>Returns the 4D form of this 2D vector, with the z and w
coordinates set to zero.</p>
<p><b>See also</b> <a href="qvector2d.html#toVector3D">toVector3D</a>() and <a href="qvector2d.html#toPoint">toPoint</a>().</p>


<h3 class="fn"><a name="x" />float QVector2D.x (<i>self</i>)</h3><p>Returns the x coordinate of this point.</p>
<p><b>See also</b> <a href="qvector2d.html#setX">setX</a>() and
<a href="qvector2d.html#y">y</a>().</p>


<h3 class="fn"><a name="y" />float QVector2D.y (<i>self</i>)</h3><p>Returns the y coordinate of this point.</p>
<p><b>See also</b> <a href="qvector2d.html#setY">setY</a>() and
<a href="qvector2d.html#x">x</a>().</p>


<h3 class="fn"><a name="__add__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__add__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>v2</i>)</h3><h3 class="fn"><a name="__div__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__div__ (<i>self</i>, float&#160;<i>divisor</i>)</h3><h3 class="fn"><a name="__eq__" />bool QVector2D.__eq__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>v2</i>)</h3><h3 class="fn"><a name="__iadd__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__iadd__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>vector</i>)</h3><h3 class="fn"><a name="__idiv__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__idiv__ (<i>self</i>, float&#160;<i>divisor</i>)</h3><h3 class="fn"><a name="__imul__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__imul__ (<i>self</i>, float&#160;<i>factor</i>)</h3><h3 class="fn"><a name="__imul__-2" /><a href="qvector2d.html">QVector2D</a> QVector2D.__imul__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>vector</i>)</h3><h3 class="fn"><a name="__isub__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__isub__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>vector</i>)</h3><h3 class="fn"><a name="__mul__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__mul__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>vector</i>)</h3><h3 class="fn"><a name="__mul__-2" /><a href="qvector2d.html">QVector2D</a> QVector2D.__mul__ (<i>self</i>, float&#160;<i>factor</i>)</h3><h3 class="fn"><a name="__mul__-3" /><a href="qvector2d.html">QVector2D</a> QVector2D.__mul__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>v2</i>)</h3><h3 class="fn"><a name="__ne__" />bool QVector2D.__ne__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>v2</i>)</h3><h3 class="fn"><a name="__neg__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__neg__ (<i>self</i>)</h3><h3 class="fn"><a name="__repr__" />str QVector2D.__repr__ (<i>self</i>)</h3><h3 class="fn"><a name="__sub__" /><a href="qvector2d.html">QVector2D</a> QVector2D.__sub__ (<i>self</i>, <a href="qvector2d.html">QVector2D</a>&#160;<i>v2</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>